<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>std::basic_istream</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/io/basic_istream","wgTitle":"cpp/io/basic istream","wgCurRevisionId":52061,"wgArticleId":2254,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/io/basic_istream","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_io_basic_istream skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::</span>basic_istream</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../io.html" title="cpp/io">io</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility">工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../ranges.html" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../io.html" title="cpp/io">输入/输出库</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="manip.html" title="cpp/io/manip"> I/O 操纵符</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="c.html" title="cpp/io/c"> C 风格 I/O</a></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 缓冲 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_streambuf.html" title="cpp/io/basic streambuf"><span class="t-lines"><span>basic_streambuf</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_filebuf.html" title="cpp/io/basic filebuf"><span class="t-lines"><span>basic_filebuf</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_stringbuf.html" title="cpp/io/basic stringbuf"><span class="t-lines"><span>basic_stringbuf</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="strstreambuf.html" title="cpp/io/strstreambuf"><span class="t-lines"><span>strstreambuf</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(C++98 中弃用)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_syncbuf.html" title="cpp/io/basic syncbuf"><span class="t-lines"><span>basic_syncbuf</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 流 </td></tr>
<tr class="t-nv-h2"><td colspan="5"> 抽象 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ios_base.html" title="cpp/io/ios base"><span class="t-lines"><span>ios_base</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ios.html" title="cpp/io/basic ios"><span class="t-lines"><span>basic_ios</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>basic_istream</span></span></strong></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ostream.html" title="cpp/io/basic ostream"><span class="t-lines"><span>basic_ostream</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_iostream.html" title="cpp/io/basic iostream"><span class="t-lines"><span>basic_iostream</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 文件 I/O </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ifstream.html" title="cpp/io/basic ifstream"><span class="t-lines"><span>basic_ifstream</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ofstream.html" title="cpp/io/basic ofstream"><span class="t-lines"><span>basic_ofstream</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_fstream.html" title="cpp/io/basic fstream"><span class="t-lines"><span>basic_fstream</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 字符串 I/O </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istringstream.html" title="cpp/io/basic istringstream"><span class="t-lines"><span>basic_istringstream</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_ostringstream.html" title="cpp/io/basic ostringstream"><span class="t-lines"><span>basic_ostringstream</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_stringstream.html" title="cpp/io/basic stringstream"><span class="t-lines"><span>basic_stringstream</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 数组 I/O </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="istrstream.html" title="cpp/io/istrstream"><span class="t-lines"><span>istrstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(C++98 中弃用)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ostrstream.html" title="cpp/io/ostrstream"><span class="t-lines"><span>ostrstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(C++98 中弃用)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="strstream.html" title="cpp/io/strstream"><span class="t-lines"><span>strstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-deprecated-cxx98">(C++98 中弃用)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 同步的输出</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_osyncstream.html" title="cpp/io/basic osyncstream"><span class="t-lines"><span>basic_osyncstream</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 类型 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="streamoff.html" title="cpp/io/streamoff"><span class="t-lines"><span>streamoff</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="streamsize.html" title="cpp/io/streamsize"><span class="t-lines"><span>streamsize</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="fpos.html" title="cpp/io/fpos"><span class="t-lines"><span>fpos</span></span></a></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 错误类别接口 </td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="iostream_category.html" title="cpp/io/iostream category"><span class="t-lines"><span>iostream_category</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="io_errc.html" title="cpp/io/io errc"><span class="t-lines"><span>io_errc</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><strong class="selflink"><tt>std::basic_istream</tt></strong><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 全局对象</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="cin.html" title="cpp/io/cin"><span class="t-lines"><span>cin</span><span>wcin</span></span></a></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 成员函数</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/basic_istream.html" title="cpp/io/basic istream/basic istream"><span class="t-lines"><span>basic_istream::basic_istream</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/~basic_istream.html" title="cpp/io/basic istream/~basic istream"><span class="t-lines"><span>basic_istream::~basic_istream</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/operator%3D.html" title="cpp/io/basic istream/operator="><span class="t-lines"><span>basic_istream::operator=</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 有格式输入</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/operator_gtgt.html" title="cpp/io/basic istream/operator gtgt"><span class="t-lines"><span>basic_istream::operator&gt;&gt;</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 无格式输入</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/get.html" title="cpp/io/basic istream/get"><span class="t-lines"><span>basic_istream::get</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/peek.html" title="cpp/io/basic istream/peek"><span class="t-lines"><span>basic_istream::peek</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/unget.html" title="cpp/io/basic istream/unget"><span class="t-lines"><span>basic_istream::unget</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/putback.html" title="cpp/io/basic istream/putback"><span class="t-lines"><span>basic_istream::putback</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/getline.html" title="cpp/io/basic istream/getline"><span class="t-lines"><span>basic_istream::getline</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/ignore.html" title="cpp/io/basic istream/ignore"><span class="t-lines"><span>basic_istream::ignore</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/read.html" title="cpp/io/basic istream/read"><span class="t-lines"><span>basic_istream::read</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/readsome.html" title="cpp/io/basic istream/readsome"><span class="t-lines"><span>basic_istream::readsome</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/gcount.html" title="cpp/io/basic istream/gcount"><span class="t-lines"><span>basic_istream::gcount</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 定位</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/tellg.html" title="cpp/io/basic istream/tellg"><span class="t-lines"><span>basic_istream::tellg</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/seekg.html" title="cpp/io/basic istream/seekg"><span class="t-lines"><span>basic_istream::seekg</span></span></a></div></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 杂项</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://zh.cppreference.com/w/cpp/io/basic_istream/sync" title="cpp/io/basic istream/sync"><span class="t-lines"><span>basic_istream::sync</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/swap.html" title="cpp/io/basic istream/swap"><span class="t-lines"><span>basic_istream::swap</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 成员类</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/sentry.html" title="cpp/io/basic istream/sentry"><span class="t-lines"><span>basic_istream::sentry</span></span></a></div></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 非成员函数</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream/operator_gtgt2.html" title="cpp/io/basic istream/operator gtgt2"><span class="t-lines"><span>operator&gt;&gt;<span class="t-dsc-small">(std::basic_istream)</span></span></span></a></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="t-dcl-begin"><tbody>
<tr class="t-dsc-header">
<td> <div>定义于头文件 <code><a href="../header/istream.html" title="cpp/header/istream">&lt;istream&gt;</a></code>
 </div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl">
<td class="t-dcl-nopad"> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <br>
<p>    <span class="kw1">class</span> CharT, <br>
    <span class="kw1">class</span> Traits <span class="sy1">=</span> <a href="../string/char_traits.html"><span class="kw1267">std::<span class="me2">char_traits</span></span></a><span class="sy1">&lt;</span>CharT<span class="sy1">&gt;</span><br>
</p>
<span class="sy1">&gt;</span> <span class="kw1">class</span> basic_istream <span class="sy4">:</span> <span class="kw1">virtual</span> <span class="kw1">public</span> <a href="basic_ios.html"><span class="kw1712">std::<span class="me2">basic_ios</span></span></a><span class="sy1">&lt;</span>CharT, Traits<span class="sy1">&gt;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td class="t-dcl-nopad">  </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>类模板 <code>basic_istream</code> 提供字符流上的高层输入支持。受支持操作包含带格式的输入（例如整数值或空白符分隔的字符与字符串）和无格式输入（例如未处理字符和字符数组）。此功能以通过 <code>basic_ios</code> 基类访问的底层 <code>basic_streambuf</code> 类所提供的接口实现。大多数库实现中， <code>basic_istream</code> 有一个非继承数据成员：用于存储 <a href="basic_istream/gcount.html" title="cpp/io/basic istream/gcount"><tt>basic_istream::gcount()</tt></a> 所返回的值。
</p>
<div class="t-inheritance-diagram">
<div class="center"><div class="noresize" style="height: 45px; width: 399px; "><map name="ImageMap_1_776046837"><area href="ios_base.html" shape="rect" coords="5,6,107,39" alt="cpp/io/ios base" title="cpp/io/ios base"><area href="basic_ios.html" shape="rect" coords="135,4,252,42" alt="cpp/io/basic ios" title="cpp/io/basic ios"></map><img alt="std-basic istream-inheritance.svg" src="../../../common/images/d/db/std-basic_istream-inheritance.svg" width="399" height="45" usemap="#ImageMap_1_776046837"></div></div>
<div style="text-align:center;">
<p><span style="font-size:0.7em; line-height:130%">继承图</span>
</p>
</div>
</div>
<p>它对常用字符类型定义了二个具体类：
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;istream&gt;</code> </div>
</td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td> 类型
</td>
<td> 定义
</td></tr>


<tr class="t-dsc">
<td>  <code>istream</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">basic_istream<span class="sy1">&lt;</span><span class="kw4">char</span><span class="sy1">&gt;</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <code>wistream</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">basic_istream<span class="sy1">&lt;</span><span class="kw4">wchar_t</span><span class="sy1">&gt;</span></span></span>
</td></tr>
</table>
<h3><span class="mw-headline" id=".E5.85.A8.E5.B1.80.E5.AF.B9.E8.B1.A1">全局对象</span></h3>
<p>标准库提供二个全局 basic_istream 对象。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-header">
<td colspan="2"> <div>定义于头文件 <code>&lt;iostream&gt;</code> </div>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="cin.html" title="cpp/io/cin"> <span class="t-lines"><span>cin</span><span>wcin</span></span></a></div></div>
</td>
<td>  从标准 C 输入流 <span class="t-lc"><a href="c.html" title="cpp/io/c">stdin</a></span> 中读取<br><span class="t-mark">(全局对象)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E7.B1.BB.E5.9E.8B">成员类型</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td> 成员类型
</td>
<td> 定义
</td></tr>


<tr class="t-dsc">
<td>  <code>char_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">CharT</span></span></td></tr>

<tr class="t-dsc">
<td>  <code>traits_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits</span></span> ；若 <code>Traits::char_type</code> 不是 <code>CharT</code> 则程序为谬构。</td></tr>

<tr class="t-dsc">
<td>  <code>int_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits<span class="sy4">::</span><span class="me2">int_type</span></span></span></td></tr>

<tr class="t-dsc">
<td>  <code>pos_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits<span class="sy4">::</span><span class="me2">pos_type</span></span></span></td></tr>

<tr class="t-dsc">
<td>  <code>off_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits<span class="sy4">::</span><span class="me2">off_type</span></span></span></td></tr>
</table>
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0">成员函数</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div t-dsc-member-nobold-div"><div><a href="basic_istream/basic_istream.html" title="cpp/io/basic istream/basic istream"> <span class="t-lines"><span>(构造函数)</span></span></a></div></div>
</td>
<td>  构造对象 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div t-dsc-member-nobold-div"><div><a href="basic_istream/~basic_istream.html" title="cpp/io/basic istream/~basic istream"> <span class="t-lines"><span>(析构函数)</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[虚]</span></span></span></div></div>
</td>
<td>  析构对象 <br> <span class="t-mark">(虚公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/operator%3D.html" title="cpp/io/basic istream/operator="> <span class="t-lines"><span>operator=</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  从另一 <code>basic_istream</code> 移动赋值 <br> <span class="t-mark">(受保护成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E5.B8.A6.E6.A0.BC.E5.BC.8F.E7.9A.84.E8.BE.93.E5.85.A5"> 带格式的输入 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/operator_gtgt.html" title="cpp/io/basic istream/operator gtgt"> <span class="t-lines"><span>operator&gt;&gt;</span></span></a></div></div>
</td>
<td>  提取带格式数据 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.97.A0.E6.A0.BC.E5.BC.8F.E8.BE.93.E5.85.A5"> 无格式输入 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/get.html" title="cpp/io/basic istream/get"> <span class="t-lines"><span>get</span></span></a></div></div>
</td>
<td>  从流中读并取走（移除类似指针向下一个元素移动）一个字符 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/peek.html" title="cpp/io/basic istream/peek"> <span class="t-lines"><span>peek</span></span></a></div></div>
</td>
<td>  仅读出但不取走（不移除类似指针并未移动）一个字符 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/unget.html" title="cpp/io/basic istream/unget"> <span class="t-lines"><span>unget</span></span></a></div></div>
</td>
<td>  撤销流中刚取走（移除，类似指针向后退回一个位置）的字符 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/putback.html" title="cpp/io/basic istream/putback"> <span class="t-lines"><span>putback</span></span></a></div></div>
</td>
<td>  往输入流中退回一个字符 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/getline.html" title="cpp/io/basic istream/getline"> <span class="t-lines"><span>getline</span></span></a></div></div>
</td>
<td>  一直读并取走字符，直至找到给定字符 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/ignore.html" title="cpp/io/basic istream/ignore"> <span class="t-lines"><span>ignore</span></span></a></div></div>
</td>
<td>  读且取走并舍弃字符，直至发现给定字符 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/read.html" title="cpp/io/basic istream/read"> <span class="t-lines"><span>read</span></span></a></div></div>
</td>
<td>  读并取走一块字符 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/readsome.html" title="cpp/io/basic istream/readsome"> <span class="t-lines"><span>readsome</span></span></a></div></div>
</td>
<td>  读并取走已经可用的字符块 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/gcount.html" title="cpp/io/basic istream/gcount"> <span class="t-lines"><span>gcount</span></span></a></div></div>
</td>
<td>  返回上次无格式输出操作所取走的字符数量 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E5.AF.BB.E4.BD.8D"> 寻位 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/tellg.html" title="cpp/io/basic istream/tellg"> <span class="t-lines"><span>tellg</span></span></a></div></div>
</td>
<td>  返回输入位置指示器 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/seekg.html" title="cpp/io/basic istream/seekg"> <span class="t-lines"><span>seekg</span></span></a></div></div>
</td>
<td>   设置输入位置指示器  <br> <span class="t-mark">(公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.9D.82.E9.A1.B9"> 杂项 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="https://zh.cppreference.com/w/cpp/io/basic_istream/sync" title="cpp/io/basic istream/sync"> <span class="t-lines"><span>sync</span></span></a></div></div>
</td>
<td>  与底层存储设备同步 <br> <span class="t-mark">(公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/swap.html" title="cpp/io/basic istream/swap"> <span class="t-lines"><span>swap</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  交换流对象，除了关联的缓冲区 <br> <span class="t-mark">(受保护成员函数)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E6.88.90.E5.91.98.E7.B1.BB">成员类</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/sentry.html" title="cpp/io/basic istream/sentry"> <span class="t-lines"><span>sentry</span></span></a></div></div>
</td>
<td>  实现为输出操作准备流的基本逻辑 <br> <span class="t-mark">(公开成员类)</span> </td></tr>
</table>
<h3><span class="mw-headline" id=".E9.9D.9E.E6.88.90.E5.91.98.E5.87.BD.E6.95.B0">非成员函数</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_istream/operator_gtgt2.html" title="cpp/io/basic istream/operator gtgt2"> <span class="t-lines"><span>operator&gt;&gt;<span class="t-dsc-small">(std::basic_istream)</span></span></span></a></div></div>
</td>
<td>  提取字符和字符数组 <br> <span class="t-mark">(函数模板)</span> </td></tr>
</table>
<div class="t-inherited">
<h2> <span class="mw-headline" id=".E7.BB.A7.E6.89.BF.E8.87.AA_std::basic_ios">继承自  <a href="basic_ios.html" title="cpp/io/basic ios"> <span style="font-size:0.7em; line-height:130%">std::</span>basic_ios</a> </span></h2>
<h3> <span class="mw-headline" id=".E6.88.90.E5.91.98.E7.B1.BB.E5.9E.8B_2">成员类型</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td>  成员类型
</td>
<td>  定义
</td></tr>


<tr class="t-dsc">
<td>  <code>char_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">CharT</span></span>
</td></tr>

<tr class="t-dsc">
<td>  <code>traits_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits</span></span>
</td></tr>

<tr class="t-dsc">
<td>  <code>int_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits<span class="sy4">::</span><span class="me2">int_type</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <code>pos_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits<span class="sy4">::</span><span class="me2">pos_type</span></span></span>
</td></tr>

<tr class="t-dsc">
<td>  <code>off_type</code>
</td>
<td>  <span class="t-c"><span class="mw-geshi cpp source-cpp">Traits<span class="sy4">::</span><span class="me2">off_type</span></span></span>
</td></tr>
</table>
<h3> <span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0_2">成员函数</span></h3>
<table class="t-dsc-begin">

<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E7.8A.B6.E6.80.81.E5.87.BD.E6.95.B0">  状态函数 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/good.html" title="cpp/io/basic ios/good"> <span class="t-lines"><span>good</span></span></a></div></div>
</td>
<td>   检查是否没有发生错误，例如是否可执行I/O操作  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/eof.html" title="cpp/io/basic ios/eof"> <span class="t-lines"><span>eof</span></span></a></div></div>
</td>
<td>   检查是否到达了文件末尾  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/fail.html" title="cpp/io/basic ios/fail"> <span class="t-lines"><span>fail</span></span></a></div></div>
</td>
<td>   检查是否发生了可恢复的错误  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/bad.html" title="cpp/io/basic ios/bad"> <span class="t-lines"><span>bad</span></span></a></div></div>
</td>
<td>  检查是否已发生不可恢复的错误 <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/operator%21.html" title="cpp/io/basic ios/operator!"> <span class="t-lines"><span>operator!</span></span></a></div></div>
</td>
<td>   检查是否有错误发生（<a href="basic_ios/fail.html" title="cpp/io/basic ios/fail"><tt>fail()</tt></a> 的同义词） <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/operator_bool.html" title="cpp/io/basic ios/operator bool"> <span class="t-lines"><span>operator void*</span><span>operator bool</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-until-cxx11">(C++11 前)</span></span><span><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></span></span></div></div>
</td>
<td>   检查是否没有发生错误（<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy3">!</span>fail<span class="br0">(</span><span class="br0">)</span></span></span>的同义词） <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/rdstate.html" title="cpp/io/basic ios/rdstate"> <span class="t-lines"><span>rdstate</span></span></a></div></div>
</td>
<td>  返回状态标志 <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/setstate.html" title="cpp/io/basic ios/setstate"> <span class="t-lines"><span>setstate</span></span></a></div></div>
</td>
<td>  设置状态标志 <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/clear.html" title="cpp/io/basic ios/clear"> <span class="t-lines"><span>clear</span></span></a></div></div>
</td>
<td>  修改状态标志 <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.A0.BC.E5.BC.8F.E5.8C.96">  格式化 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/copyfmt.html" title="cpp/io/basic ios/copyfmt"> <span class="t-lines"><span>copyfmt</span></span></a></div></div>
</td>
<td>   复制格式化信息  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/fill.html" title="cpp/io/basic ios/fill"> <span class="t-lines"><span>fill</span></span></a></div></div>
</td>
<td>   管理填充字符  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.9D.82.E9.A1.B9_2">  杂项 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/exceptions.html" title="cpp/io/basic ios/exceptions"> <span class="t-lines"><span>exceptions</span></span></a></div></div>
</td>
<td>   管理异常掩码  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/imbue.html" title="cpp/io/basic ios/imbue"> <span class="t-lines"><span>imbue</span></span></a></div></div>
</td>
<td>  设置本地环境 <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/rdbuf.html" title="cpp/io/basic ios/rdbuf"> <span class="t-lines"><span>rdbuf</span></span></a></div></div>
</td>
<td>   管理相关的流缓冲区  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/tie.html" title="cpp/io/basic ios/tie"> <span class="t-lines"><span>tie</span></span></a></div></div>
</td>
<td>   管理绑定的流  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/narrow.html" title="cpp/io/basic ios/narrow"> <span class="t-lines"><span>narrow</span></span></a></div></div>
</td>
<td>  窄化字符 <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="basic_ios/widen.html" title="cpp/io/basic ios/widen"> <span class="t-lines"><span>widen</span></span></a></div></div>
</td>
<td>   拓宽字符  <br> <span class="t-mark">(<code>std::basic_ios&lt;CharT,Traits&gt;</code> 的公开成员函数)</span> </td></tr>
</table>
</div>
<div class="t-inherited">
<h2> <span class="mw-headline" id=".E7.BB.A7.E6.89.BF.E8.87.AA_std::ios_base">继承自  <a href="ios_base.html" title="cpp/io/ios base"> <span style="font-size:0.7em; line-height:130%">std::</span>ios_base</a> </span></h2>
<h3> <span class="mw-headline" id=".E6.88.90.E5.91.98.E5.87.BD.E6.95.B0_3">成员函数</span></h3>
<table class="t-dsc-begin">


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.A0.BC.E5.BC.8F.E5.8C.96_2">  格式化 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/flags.html" title="cpp/io/ios base/flags"> <span class="t-lines"><span>flags</span></span></a></div></div>
</td>
<td>  管理格式标志 <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/setf.html" title="cpp/io/ios base/setf"> <span class="t-lines"><span>setf</span></span></a></div></div>
</td>
<td>  设置特定格式标志 <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/unsetf.html" title="cpp/io/ios base/unsetf"> <span class="t-lines"><span>unsetf</span></span></a></div></div>
</td>
<td>   清除特定格式的标志  <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/precision.html" title="cpp/io/ios base/precision"> <span class="t-lines"><span>precision</span></span></a></div></div>
</td>
<td>   管理浮点操作的精度  <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/width.html" title="cpp/io/ios base/width"> <span class="t-lines"><span>width</span></span></a></div></div>
</td>
<td>   管理域的宽度  <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.9C.AC.E5.9C.B0.E7.8E.AF.E5.A2.83">  本地环境 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/imbue.html" title="cpp/io/ios base/imbue"> <span class="t-lines"><span>imbue</span></span></a></div></div>
</td>
<td>  设置本地环境 <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/getloc.html" title="cpp/io/ios base/getloc"> <span class="t-lines"><span>getloc</span></span></a></div></div>
</td>
<td>  返回当前本地环境 <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E5.86.85.E9.83.A8.E5.8F.AF.E6.89.A9.E5.B1.95.E6.95.B0.E7.BB.84">  内部可扩展数组 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/xalloc.html" title="cpp/io/ios base/xalloc"> <span class="t-lines"><span>xalloc</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[静态]</span></span></span></div></div>
</td>
<td>  返回能安全用作 pword() 和 iword() 下标的程序范围内独有的整数 <br> <span class="t-mark">(<code>std::ios_base</code> 的公开静态成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/iword.html" title="cpp/io/ios base/iword"> <span class="t-lines"><span>iword</span></span></a></div></div>
</td>
<td>   如果有必要的话，调整私有存储的大小，并且访问位于提供的下标的<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">long</span></span></span>元素  <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/pword.html" title="cpp/io/ios base/pword"> <span class="t-lines"><span>pword</span></span></a></div></div>
</td>
<td>  若需要则重置私有存储的大小，并访问位于指定下标的 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">void</span><span class="sy2">*</span></span></span> 元素 <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.9D.82.E9.A1.B9_3">  杂项 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/register_callback.html" title="cpp/io/ios base/register callback"> <span class="t-lines"><span>register_callback</span></span></a></div></div>
</td>
<td>   注册事件回调函数  <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员函数)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/sync_with_stdio.html" title="cpp/io/ios base/sync with stdio"> <span class="t-lines"><span>sync_with_stdio</span></span></a></div><div><span class="t-lines"><span><span class="t-cmark">[静态]</span></span></span></div></div>
</td>
<td>   设置C++和C的IO库是否可以互操作  <br> <span class="t-mark">(<code>std::ios_base</code> 的公开静态成员函数)</span> </td></tr>


<tr>
<td colspan="2"> <h5> <span class="mw-headline" id=".E6.88.90.E5.91.98.E7.B1.BB_2">  成员类 </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/failure.html" title="cpp/io/ios base/failure"> <span class="t-lines"><span>failure</span></span></a></div></div>
</td>
<td>  流异常 <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员类)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/Init.html" title="cpp/io/ios base/Init"> <span class="t-lines"><span>Init</span></span></a></div></div>
</td>
<td>   初始化标准流对象  <br> <span class="t-mark">(<code>std::ios_base</code> 的公开成员类)</span> </td></tr>
</table>
<table class="t-dsc-begin">

<tr>
<td colspan="2"> <h3> <span class="mw-headline" id=".E6.88.90.E5.91.98.E7.B1.BB.E5.9E.8B.E5.92.8C.E5.B8.B8.E9.87.8F"> 成员类型和常量</span></h3>
</td></tr>

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td>  类型
</td>
<td>  解释
</td></tr>


<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"> <span class="t-lines"><span>openmode</span></span></a></div></div>
</td>
<td>  流打开模式类型
<p>亦定义下列常量：
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td> 常量
</td>
<td> 解释</td></tr>


<tr class="t-dsc">
<td>  <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>app</tt></a>
</td>
<td> 每次写入前寻位到流结尾</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>binary</tt></a>
</td>
<td> 以<a href="c.html#.E4.BA.8C.E8.BF.9B.E5.88.B6.E4.B8.8E.E6.96.87.E6.9C.AC.E6.A8.A1.E5.BC.8F" title="cpp/io/c">二进制模式</a>打开</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>in</tt></a>
</td>
<td> 为读打开</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>out</tt></a>
</td>
<td> 为写打开</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>trunc</tt></a>
</td>
<td> 在打开时舍弃流的内容</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/openmode.html" title="cpp/io/ios base/openmode"><tt>ate</tt></a>
</td>
<td> 打开后立即寻位到流结尾</td></tr>
</table> <br> <span class="t-mark">(typedef)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"> <span class="t-lines"><span>fmtflags</span></span></a></div></div>
</td>
<td>  格式化标志类型
<p>亦定义下列常量：
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td> 常量
</td>
<td> 解释</td></tr>


<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>dec</tt></a>
</td>
<td> 为整数 I/O 使用十进制底：见 <span class="t-lc"><a href="manip/hex.html" title="cpp/io/manip/hex">std::dec</a></span></td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>oct</tt></a>
</td>
<td> 为整数 I/O 使用八进制底：见 <span class="t-lc"><a href="manip/hex.html" title="cpp/io/manip/hex">std::oct</a></span></td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>hex</tt></a>
</td>
<td> 为整数 I/O 使用十六进制底：见 <span class="t-lc"><a href="manip/hex.html" title="cpp/io/manip/hex">std::hex</a></span></td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>basefield</tt></a>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">dec<span class="sy3">|</span>oct<span class="sy3">|</span>hex</span></span> 。适用于掩码运算</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>left</tt></a>
</td>
<td> 左校正（添加填充字符到右）：见 <span class="t-lc"><a href="manip/left.html" title="cpp/io/manip/left">std::left</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>right</tt></a>
</td>
<td> 右校正（添加填充字符到左）：见 <span class="t-lc"><a href="manip/left.html" title="cpp/io/manip/left">std::right</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>internal</tt></a>
</td>
<td> 内部校正（添加填充字符到内部选定点）：见 <span class="t-lc"><a href="manip/left.html" title="cpp/io/manip/left">std::internal</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>adjustfield</tt></a>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">left<span class="sy3">|</span>right<span class="sy3">|</span>internal</span></span> 。适用于掩码运算</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>scientific</tt></a>
</td>
<td> 用科学记数法生成浮点类型，或若与 fixed 组合则用十六进制记法：见 <span class="t-lc"><a href="manip/fixed.html" title="cpp/io/manip/fixed">std::scientific</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>fixed</tt></a>
</td>
<td> 用定点记法生成浮点类型，或若与 scientific 组合则用十六进制记法：见 <span class="t-lc"><a href="manip/fixed.html" title="cpp/io/manip/fixed">std::fixed</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>floatfield</tt></a>
</td>
<td> <span class="t-c"><span class="mw-geshi cpp source-cpp">scientific<span class="sy3">|</span>fixed</span></span> 。适用于掩码运算</td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>boolalpha</tt></a>
</td>
<td> 以字母数字格式插入并释出 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">bool</span></span></span> 类型：见 <span class="t-lc"><a href="manip/boolalpha.html" title="cpp/io/manip/boolalpha">std::boolalpha</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showbase</tt></a>
</td>
<td> 生成为整数输出指示数字基底的前缀，货币 I/O 中要求现金指示器：见 <span class="t-lc"><a href="manip/showbase.html" title="cpp/io/manip/showbase">std::showbase</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showpoint</tt></a>
</td>
<td> 无条件为浮点数输出生成小数点字符：见 <span class="t-lc"><a href="manip/showpoint.html" title="cpp/io/manip/showpoint">std::showpoint</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>showpos</tt></a>
</td>
<td> 为非负数值输出生成 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy2">+</span></span></span> 字符，见 <span class="t-lc"><a href="manip/showpos.html" title="cpp/io/manip/showpos">std::showpos</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>skipws</tt></a>
</td>
<td> 在具体输入操作前跳过前导空白符：见 <span class="t-lc"><a href="manip/skipws.html" title="cpp/io/manip/skipws">std::skipws</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>unitbuf</tt></a>
</td>
<td> 在每次输出操作后冲入输出：见 <span class="t-lc"><a href="manip/unitbuf.html" title="cpp/io/manip/unitbuf">std::unitbuf</a></span> </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/fmtflags.html" title="cpp/io/ios base/fmtflags"><tt>uppercase</tt></a>
</td>
<td> 在具体输出的输出操作中以大写等价替换小写字符：见 <span class="t-lc"><a href="manip/uppercase.html" title="cpp/io/manip/uppercase">std::uppercase</a></span> </td></tr>
</table> <br> <span class="t-mark">(typedef)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"> <span class="t-lines"><span>iostate</span></span></a></div></div>
</td>
<td>   流状态类型
<p>亦定义下列常量：
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td>  常量
</td>
<td>  解释</td></tr>


<tr class="t-dsc">
<td>  <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>goodbit</tt></a>
</td>
<td>  无错误 </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>badbit</tt></a>
</td>
<td>  不可恢复的流错误 </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>failbit</tt></a>
</td>
<td>  输入/输出操作失败（格式化或提取错误） </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/iostate.html" title="cpp/io/ios base/iostate"><tt>eofbit</tt></a>
</td>
<td>  关联的输出序列已抵达文件尾 </td></tr>
</table> <br> <span class="t-mark">(typedef)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"> <span class="t-lines"><span>seekdir</span></span></a></div></div>
</td>
<td>   寻位方向类型
<p>亦定义下列常量：
</p>
<table class="t-dsc-begin">

<tr class="t-dsc-sep">
<td colspan="2">  
</td></tr>
<tr class="t-dsc-hitem">
<td>  常量
</td>
<td>  解释</td></tr>


<tr class="t-dsc">
<td>  <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>beg</tt></a>
</td>
<td>  流的开始 </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>end</tt></a>
</td>
<td>  流的结尾 </td></tr>

<tr class="t-dsc">
<td>  <a href="ios_base/seekdir.html" title="cpp/io/ios base/seekdir"><tt>cur</tt></a>
</td>
<td>  流位置指示器的当前位置 </td></tr>
</table> <br> <span class="t-mark">(typedef)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/event.html" title="cpp/io/ios base/event"> <span class="t-lines"><span>event</span></span></a></div></div>
</td>
<td>   指定事件类型 <br> <span class="t-mark">(枚举)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="ios_base/event_callback.html" title="cpp/io/ios base/event callback"> <span class="t-lines"><span>event_callback</span></span></a></div></div>
</td>
<td>   回调函数类型 <br> <span class="t-mark">(typedef)</span> </td></tr>
</table>
</div>

<!-- 
NewPP limit report
Preprocessor visited node count: 16395/1000000
Preprocessor generated node count: 15213/1000000
Post‐expand include size: 573621/2097152 bytes
Template argument size: 151419/2097152 bytes
Highest expansion depth: 35/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:2254-0!*!0!!zh!2!zh!* and timestamp 20200211032858 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/io/basic_istream&amp;oldid=52061">https://zh.cppreference.com/mwiki/index.php?title=cpp/io/basic_istream&amp;oldid=52061</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/io/basic_istream">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2018年1月4日 (星期四) 00:55。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过21,022次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 2.131 secs. -->
	</body>
<!-- Cached 20200211032859 -->
</html>